/**
  ******************************************************************************
  * @file    ct75.h
  * @author  fanhui.meng
  * @version V1.0.0
  * @date    2019.9.20
  * @brief   
  ******************************************************************************
  */
#include "stdint.h"
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __CT75_H
#define __CT75_H

/**************************pca9545**************************************/
#define  PCA9545_ADDR      0x70
#define  CHANNEL_0_MP5416  0x01
#define  CHANNEL_1_INA220  0x02
#define  CHANNEL_2_SOC_I2C 0x04

void select_pca_channel(uint8_t channel);
void test_select_pca_channel(void);


/****************************************************************
1.  CT75 温度告警信号
*****************************************************************/
#define CT75_IRQ_CLK                      RCC_AHBPeriph_GPIOB
#define CT75_IRQ_PORT                     GPIOB
#define CT75_ALERT_PIN                    (GPIO_Pin_8)

#define CT75_EXTI_LINE                    EXTI_Line8
#define CT75_EXTI_IRQn                    EXTI4_15_IRQn
#define CT75_EXTI_PIN_SOURCE              EXTI_PinSource8
#define CT75_EXTI_PORT_SOURCE             EXTI_PortSourceGPIOB

void CT75_Alert_INIT(void);

/* Exported constants --------------------------------------------------------*/
/*CT75器件地址*/
#define CT75_WRITE_ADDR1                              0x90
#define CT75_READ_ADDR1                               0x91
#define CT75_WRITE_ADDR2                              0x94
#define CT75_READ_ADDR2                               0x95
#define CT75_WRITE_ADDR3                              0x98
#define CT75_READ_ADDR3                               0x99


/*CT75的命令寄存器地址*/
#define CT75_CMD_ADDR                            0x00
#define CT75_CMD_LOW_ALERT_ADDR                  0x02    //低于下限接触告警,默认值0x4B00(75C)
#define CT75_CMD_HIGH_ALERT_ADDR                 0x03	 //高于上限触发告警,默认值0x5000(80C)


/*CT75温度值字节长度*/
#define CT75_TEMPERATURE_NUMBER                 2

/*CT75检测温度用时,单位为0.1ms*/
#define CT75_TEMPERATURE_DEL                    45


/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
short CT75_Read_Temperature(uint16_t ct75_addr);
//void BMP085_Calculate_Temp_Pres(void);
void CT75_TIMEOUT_UserCallback(void);
void CT75_SET_ALERT_LIMIT(uint16_t ct75_addr);
int test_ct75(void);
#endif


/****AT24C02****/

int test_eeprom(void);
#define ADDR_AT24C02_Write 0xA0
#define ADDR_AT24C02_Read 0xA1

/****主从模式****/
#define I2C2_SLAVE_ADD 0X20
#define I2C1_SLAVE_ADD 0X4f
#define TEST_NUM 1
void test_slave_mode(void);
void test_i2c_write(void);
void test_i2c_read(void);
void test_bmc_func(void);
void test_slave_recive(void);

/************************ (C) COPYRIGHT ****************END OF FILE****/
